#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes) {
        int n = customers.size();
        int gap = 0;
        int sum = 0;
        for (int i = 0; i < minutes; i++)
        {
            if (grumpy[i]) gap += customers[i];
            else sum += customers[i];
        }
        int cur = gap;
        for (int i = minutes; i < n; i++)
        {
            if (grumpy[i - minutes]) cur -= customers[i - minutes];
            if (grumpy[i]) cur += customers[i];
            else sum += customers[i];
            gap = max(gap, cur);
        }
        return sum + gap;
    }
};